// part1:C13:ex13.13.cpp
// print each member of a class.
#include <iostream>
#include <ostream>
#include <vector>
using namespace std;

struct X {
  X() { cout << "constructor X()" << endl; } 
  X(const X&) { cout << "copy constructor X(const X&)" << endl; }
  X& operator=(const X &rhs) {
    cout << "copy assign operator = (const X&)" << endl;
    return *this;
  }
  ~X() { cout << "destructor ~X()" << endl; }
};

void f1(X x) {}
void f2(X &x) {}

int main(int argc, char **argv) {
  cout << "local variable: " << endl;
  X x;
  cout << endl;

  cout << "not reference arguments transfer: " << endl;
  f1(x);
  cout << endl;

  cout << "reference arguments transfer: " << endl;
  f2(x);
  cout << endl;

  cout << "dynamic allocate: " << endl;
  X *px = new X;
  cout << endl;

  cout << "add to container: " << endl;
  vector<X> vx;
  vx.push_back(x);
  cout << endl;

  cout << "release dynamic allocate object: " << endl;
  delete px;
  cout << endl;

  cout << "indirect initial and assign: " << endl;
  X y = x;
  y = x;
  cout << endl;

  cout << "program end: " << endl;
  return 0;
}
